// 格式化当前日期时间的函数
export function currentDateTime() {
    const now = new Date();
    const year = now.getFullYear();
    const month = String(now.getMonth() + 1).padStart(2, '0'); // 月份从0开始，所以+1
    const day = String(now.getDate()).padStart(2, '0');
    const hours = String(now.getHours()).padStart(2, '0');
    const minutes = String(now.getMinutes()).padStart(2, '0');
    const seconds = String(now.getSeconds()).padStart(2, '0');
    return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
export const loginSuccessTime=()=>{
    const hours = new Date().getHours();
    let msg='';
    if (hours<5){
        msg='凌晨'
    }else if (hours<9){
        msg='早上'
    }else if (hours<12){
        msg='上午'
    }else if (hours<14){
        msg='中午'
    }else if (hours<19){
        msg='下午'
    }else{
        msg='晚上'
    }
    return msg;
}

// 2024-06-01 22:13:43
export const format=(date)=>{
    const year = date.getFullYear();
    const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始，所以+1
    const day = String(date.getDate()).padStart(2, '0');
    const hours = String(date.getHours()).padStart(2, '0');
    const minutes = String(date.getMinutes()).padStart(2, '0');
    const seconds = String(date.getSeconds()).padStart(2, '0');
    return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
